import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import pinia from './store/index.js'
import router from './router'
import directives from './directives'
import { dict, getDictLabel } from './dict'
import { useStorage } from './utils/storage.js'
const app = createApp(App)
document.title = import.meta.env.VITE_APP_TITLE
if (import.meta.env.VITE_APP_USE_MOCK==='true') {
  import('./api/mock/index.js').then(() => {
    console.log('开启mock接口')
  })
}
app.config.globalProperties.$dict = {
  ...dict
}

app.config.globalProperties.$getDictLabel = getDictLabel
app.config.globalProperties.$storage = {
  local: (key, defaultValue) => useStorage(key, defaultValue),
  session: (key, defaultValue) => useStorage(key, defaultValue, { type: 'session' }),
  secure: (key, defaultValue) => useStorage(key, defaultValue, { encrypt: true })
}
app.use(ElementPlus,{
    locale: zhCn
})
app.use(directives)
app.use(router)
app.use(pinia)
app.mount('#app')
